package com.settlement.system.rules;

import com.settlement.system.model.entity.SysAudit;
import com.settlement.system.model.entity.SysAuditRule;

import java.math.BigDecimal;

/**
 * 10、未收款已退货
 * （未发货仅退款）
 */
public class NotSendGoodsRefundOnlyRuler implements CommonRuler{
    @Override
    public boolean check(SysAudit sysAudit, SysAuditRule auditRule) {
        // "应收账余额=0
        //且收款金额=0
        //且退款金额+保证金退款金额=0
        //且发货金额＞0
        //且退货金额＜0
        //且发货金额+退货金额=0"
        return BigDecimal.ZERO.compareTo(sysAudit.getReceiveBillAmount()) == 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getReceiveAmount()) == 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getRefundAmount().add(sysAudit.getDepositAmount())) == 0 &&
                sysAudit.getSendAmount().compareTo(BigDecimal.ZERO) > 0 &&
                sysAudit.getReturnAmount().compareTo(BigDecimal.ZERO) < 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getSendAmount().add(sysAudit.getReturnAmount())) == 0;
    }
}
